﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using KCMS.BusinessLogic.Models;

namespace KCMS.Areas.Admin.Engine
{
    public class ImageProcessor
    {
        public Picture Image { get; private set; }
        public ImageProcessor(HttpPostedFileBase file):this(file,new Picture())
        {
        }
        public ImageProcessor(HttpPostedFileBase file, Picture image)
        {
            Image = image;
            if (file != null)
            {
                int imageLength = file.ContentLength;
                byte[] imgBytes = new byte[imageLength];
                file.InputStream.Read(imgBytes, 0, imageLength);

                Image.ImageMimeType = file.ContentType;
                Image.Title = file.FileName;
                Image.ImageData = imgBytes;
            }
            else
            {
                throw new NullReferenceException();
            }
        }
        public Picture getThumb(Picture image)
        {
            return null;
        }
        public Picture getThumb()
        {
            return getThumb(Image);
        }
    }
}